#include "containerWrapper.h"
#include "behaviour.h"
#include "deleteCustomClasses.h"

StackI::StackI()
{ 
	size = 0; 
}


void StackI::push(Behaviour *b)
{ 
	stack_intern.push(b); 
	size++; 
}


void StackI::pop()
{ 
	Behaviour* temp = stack_intern.top();
	stack_intern.pop(); 
	DeleteCustomClass::Delete(temp);
	size--; 
}

Behaviour* StackI::peek()
{ 
	if (size > 0) 
		return stack_intern.top(); 
	else
		return NULL;
}

bool StackI::isEmpty()
{
	if (size > 0)
		return false;

	return true;
}

bool StackI::updateBehaviour(float _deltaSeconds)
{
	
	switch (peek()->getBehaviourType())
	{
	case BehaviourTypes::FLEE:
		return peek()->update(_deltaSeconds);
	break;

	default:
		return false;
	}
}

bool StackI::behaviourHigherPriorityThanStack(Behaviour* newBehaviour)
{
	if (size == 0)
		return true;

	if (newBehaviour->getBehaviourType() != stack_intern.top()->getBehaviourType())
	{
		if (newBehaviour->getBehaviourPriorityValue() > stack_intern.top()->getBehaviourPriorityValue())
		{
			return true;
		}
	}

	return false;
}

StackI::~StackI()
{
	for (int i = 0; i < size; i++)
	{
		Behaviour* temp = stack_intern.top();
		stack_intern.pop();
		
		DeleteCustomClass::Delete(temp);
	}
}



ActionList::~ActionList()
{
	for (int i = size - 1; i >= 0 ; i--)
	{
		Action* temp = vector_intern[i];
		vector_intern.pop_back();
		DeleteCustomClass::Delete(temp);
//		delete temp;
	}
}




EventList::~EventList()
{
	for (int i = size - 1; i >= 0 ; i--)
	{
		Event* temp = vector_intern[i];
		vector_intern.pop_back();
		DeleteCustomClass::Delete(temp);
//		delete temp;
	}
}



BehaviourList::~BehaviourList()
{
	for (int i = size - 1; i >= 0 ; i--)
	{
		Behaviour* temp = vector_intern[i];
		vector_intern.pop_back();
		DeleteCustomClass::Delete(temp);
//		delete temp;
	}
}




